﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using eTerm.NetSocket;
using System.Web.Script.Serialization;

namespace WebeTerm.PlugIns
{

    /// <summary>
    /// 结果属性标识，用反射显示.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class ResultAttribute : Attribute {

        public string Title { get; set; }

        public string Description { get; set; }

        public Type ValueTypeOf { get; set; }

        public int Sequence { get; set; }
    }

    /// <summary>
    /// 插件分类结果基类
    /// </summary>
    public abstract class BasePlugInResult
    {
        /// <summary>
        /// 操作员工标识
        /// </summary>
        [Result(Title = @"操作员工标识", Description = @"订票员工ID号，用于标识机票所属的销售人员",ValueTypeOf=typeof(string))]
        public string EmployeeNo { get; set; }

        /// <summary>
        /// 配置编码
        /// </summary>
        [Result(Title = @"插件编码", Description = @"公司插件编码", ValueTypeOf = typeof(string))]
        public string PlugInId { get; set; }

        /// <summary>
        /// eTerm结果原始信息
        /// </summary>
        [Result(Title = @"eTerm原始信息", Description = @"eTerm服务器返回的原始信息", ValueTypeOf = typeof(string))]
        public string OriginalMessage { get; set; }

        /// <summary>
        /// 转换为显示字符串
        /// </summary>
        /// <returns></returns>
        public virtual string ToDisplay() {
            return ToString();
        }

        /// <summary>
        /// 即时通知格式化
        /// </summary>
        /// <returns></returns>
        public virtual string ToImmediately() {
            return ToDisplay();
        }

        /// <summary>
        /// 邮件通知格式化
        /// </summary>
        /// <returns></returns>
        public virtual string ToEmail() {
            return ToString();
        }

        /// <summary>
        /// 数据存储格式化
        /// </summary>
        /// <returns></returns>
        public virtual string ToJSON() {
            JavaScriptSerializer jss = new JavaScriptSerializer();
            return jss.Serialize(this);
        }
    }

    /// <summary>
    /// 插件配置类型
    /// </summary>
    public abstract class BasePlugInConfig {

        
    }


    public class eTermConfig {
        /// <summary>
        /// Gets or sets the type of the decimal term session.
        /// </summary>
        /// <value>The type of the decimal term session.</value>
        public SocketConnectType eTermSessionType { get; set; }


        public string eTermAddress { get; set; }


        public int eTermPort { get; set; }

        public string userName { get; set; }

        public string Password { get; set; }

        public string siText { get; set; }

        public byte RID { get; set; }

        public byte SID { get; set; }
    }
}
